home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / Aztec C v5.2a disk 2.adf / examples.lzh / getfile / testing.c < prev   
C/C++ Source or Header  |  1991-10-23  |  2KB  |  97 lines

  1. #include <exec/types.h>
  2. #include <intuition/intuition.h>
  3.  
  4. #include <libraries/dosextens.h>
  5.  
  6. #include <functions.h>
  7.  
  8. #define I_REV   31
  9. #define G_REV   31
  10.  
  11. #define    EWDTH    640
  12. #define    EHGHT    198
  13.  
  14. #define    NL    NULL
  15.  
  16.  
  17. struct IntuitionBase *IntuitionBase;
  18. struct GfxBase  { int b; } *GfxBase;
  19.  
  20. struct NewScreen TS = {
  21.     0,0,640,200,2,
  22.     1,2,
  23.     HIRES,    WBENCHSCREEN,
  24.     0L, 0L, 0L
  25.     };
  26.  
  27. /* Used to open a Window   */
  28. struct NewWindow EdWindow = {
  29.     0,2,EWDTH,EHGHT-2,        /* LeftEdge,TopEdge,Width,Height */
  30.     1,2,            /* DetailPen,BlockPen    */
  31.     MENUPICK | NEWSIZE | REFRESHWINDOW | ACTIVEWINDOW |
  32.     MOUSEBUTTONS | RAWKEY | MOUSEMOVE,
  33.     WINDOWDRAG | WINDOWSIZING | SIMPLE_REFRESH | ACTIVATE | WINDOWDEPTH,
  34.     NL,NL,(UBYTE *)"Window",        /* FirstGadget, CheckMark, Title  */
  35.     NL,                /* Screen ( Null)    */
  36.     NL,                /* BitMap        */
  37.     150,45,32767,32767,        /* MinW, MinH, MaxW, MaxH */
  38.     CUSTOMSCREEN };        /* Type            */
  39.  
  40.  
  41. main()
  42. {
  43. struct Window    *eW;
  44. struct Screen    *eS;
  45.  
  46. struct Process    *OurTask;
  47. struct Window    *old_pr_WindowPtr;
  48.  
  49. static char    def_name[50] = "Meps";
  50. static char    def_dir[50] = "df1:";
  51.  
  52.     if ( ! (IntuitionBase = (struct IntuitionBase *)
  53.     OpenLibrary((UBYTE *)"intuition.library",(long)I_REV)) ||
  54.     ! (GfxBase =(struct GfxBase *)OpenLibrary((UBYTE *)"graphics.library",
  55.                                                     (long)G_REV)) )
  56.     {
  57.     printf("Can't open libraries\n");
  58.     exit(20);
  59.     }
  60.  
  61.     if ( ! (eS = (struct Screen *)OpenScreen(&TS)) )
  62.     {
  63.     printf("Can't Open Screen!!!!!\n");
  64.     exit(22);
  65.     }
  66.  
  67.     EdWindow.Screen = eS;
  68.  
  69.     if ( ! (eW =(struct Window *)OpenWindow(&EdWindow)) )
  70.     {
  71.     CloseScreen(eS);
  72.     printf("Can't open window...\n");
  73.     exit(21);
  74.     }
  75.  
  76.     /* CAUTION!!! KNOW ABOUT pr_WindowPtr before you use it!!! */
  77.  
  78.     OurTask = (struct Process *)FindTask(0L);
  79.     old_pr_WindowPtr = (struct Window *)OurTask->pr_WindowPtr;
  80.     OurTask->pr_WindowPtr = (APTR)eW;
  81.  
  82.     get_fname(eW,eS,"Nicht",def_name,def_dir);
  83.  
  84.     printf("File name is :%s\n",def_name);
  85.     printf("Directory is :%s\n",def_dir);
  86.  
  87.     /* ALWAYS RESTORE pr_WindowPtr BEFORE CLOSING THE WINDOW!!! */
  88.     OurTask->pr_WindowPtr = (APTR)old_pr_WindowPtr;
  89.  
  90.     CloseWindow(eW);
  91.     CloseScreen(eS);
  92.     
  93.     CloseLibrary((struct Library *)GfxBase);
  94.     CloseLibrary((struct Library *)IntuitionBase);
  95. }
  96.  
  97.